package com.prs.crm.action.oa;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.annotation.Clew;
import com.prs.crm.domain.oa.InformPredefineFlow;
import com.prs.crm.domain.oa.PredefineFlow;
import com.prs.crm.service.oa.InformPredefineFlowService;
import com.prs.crm.service.oa.PredefineFlowService;
/**
 * @author YangHao
 * @E-Mail:450098606@qq.com
 * @qq:450098606
 * @version 创建时间：2012-5-7 15:31:01 通知预定义流程
 */
public class InformPredefineFlowAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private InformPredefineFlow informPredefineFlow;
	private InformPredefineFlowService informPredefineFlowService;
	private PaginationSupport pagination;
	private Integer[] ids;

	public InformPredefineFlow getInformPredefineFlow() {
		return informPredefineFlow;
	}
	public void setInformPredefineFlow(InformPredefineFlow informPredefineFlow) {
		this.informPredefineFlow = informPredefineFlow;
	}
	public InformPredefineFlowService getInformPredefineFlowService() {
		return informPredefineFlowService;
	}
	public void setInformPredefineFlowService(
			InformPredefineFlowService informPredefineFlowService) {
		this.informPredefineFlowService = informPredefineFlowService;
	}
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	@Action("listInformPredefineFlow")
	public String listInformPredefineFlow(){
		DetachedCriteria crireria=this.getPaginationHelper().createQuery(InformPredefineFlow.class);
		pagination=this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getInformPredefineFlowService().listByPage(crireria, pagination));
		return SUCCESS;
	}
	@Action("editInformPredefineFlow")
	public String editInformPredefineFloe(){
		return SUCCESS;
	}
	@Clew(results = { "success", "none" })
	@Action(value = "saveInformPredefineFlow", results = {
			@Result(name = "success", type = "redirect", location = "listInformPredefineFlow"),
			@Result(name = "error", type = "chain", location = "editInformPredefineFlow"),
		 })
	public String saveInformPredefineFlow(){
		this.getInformPredefineFlowService().save(informPredefineFlow);
		this.setPrompt("添加成功！");
		return SUCCESS;
	}
	
	@Action(value = "removeInformPredefineFlow", results = {
			@Result(name = "success", type = "redirect", location = "listInformPredefineFlow"),
			@Result(name = "error", type = "chain", location = "listInformPredefineFlow"), })
	public String removeInformPredefineFlow(){
		if (ids==null) {
			this.addActionError("请选择一行进行操作！");
			return ERROR;
		}
		this.getInformPredefineFlowService().batchRemove(ids);
		return SUCCESS;
	}
}
